<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <section>
            <section @click="handleClick('demo')">demo</section>
            <section @click="handleClick('demo1')">demo1</section>
            <section @click="handleClick('demo2')">demo2</section>
            <!-- 通过component绑定了组件名称 componentId -->
            <component :is="componentId"></component>
        </section>
    </div>
</body>
<script src="../js/vue.js"></script>
<script>
    Vue.component("demo",{
        template:`
            <section>组件模板一</section>
        `
    })
    Vue.component("demo1",{
        template:`
            <section>组件模板二</section>
        `
    })
    Vue.component("demo2",{
        template:`
            <section>组件模板三</section>
        `
    })
    let vm=new Vue({
        el:"#app",
        data:{
            componentId:"demo"
        },
        methods:{
            handleClick:function(id){
                this.componentId= id;
            }
        }
    })
</script>
</html>